<template>
  <BasicModal v-bind="$attrs" @register="registerModal" :defaultFullscreen="true" :destroyOnClose="true" title="监控详情" :width="800" :showCancelBtn="false" :showOkBtn="false" @ok="handleSubmit">
    <div class="container-monitoring">
      <page-list :pageOption="pageOption" ref="tableRef" class="tableRef" />
    </div>
  </BasicModal>
</template>

<script lang="ts" setup>
// @ts-nocheck
import PageList from '../../../components/newPageList/index.vue';
import { useModal, BasicModal, useModalInner } from '/@/components/Modal';
import { summaryList } from '../../checkIn1/HubTeamMonitoring1/api.ts';
import { list } from '../../checkIn3/HubTeamResultSummarizing/service.ts';

const emit = defineEmits(['register', 'success']);
const tableRef = ref(null);
const props = defineProps({
  pageListUrl: String,
});

let pageParams = ref({
  orgCode: '',
  periodCode: '',
});

const [registerModal, { setModalProps, closeModal }] = useModalInner((data) => {
  console.log('data', data);
  // if (data.isMonth) {
  pageParams.value.orgCode = data.record.orgCode;
  pageParams.value.periodCode = data.record.periodCode;
  tableRef.value?.reload({
    searchInfo: {
      // orgCode: data.record.orgCode,
      // periodCode: data.record.periodCode,
      ...pageParams.value,
    },
  });
  // list({ orgCode: data.record.orgCode, periodCode: data.record.periodCode }).then((res) => {
  //   tableRef.value?.setTableData(res.list);
  // });
  // } else {
  //   summaryList({ orgCode: data.record.orgCode, periodCode: data.record.periodCode }).then((res) => {
  //     tableRef.value?.setTableData(res.list);
  //   });
  // }
  tableRef.value?.setColumns(data.columns);
});
const pageOption = {
  dataUrl: props.pageListUrl,
  useUrl: true,
  method: 'GET',
  showCreate: false,
  batchEdit: false,
  showActionColumn: false,
  useBatchDelete: false,
  showSearchForm: false,
  noSelection: true,
  showTableTitle: false,
  immediate: false,
  beforeFetch: (params) => {
    return Object.assign(params, { orgCode: pageParams.value.orgCode, periodCode: pageParams.value.periodCode });
  },
  columns: [],
};
</script>

<style lang="less" scoped>
.container-monitoring {
  margin-top: 12px;
  width: 100%;
}
</style>
